//
//  main.m
//  冒泡排序
//
//  Created by clz on 2019/6/17.
//  Copyright © 2019年 clz. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        
        int a[5] = {8,7,6,4,5};
        int length = sizeof(a)/sizeof(int);
        //冒泡
        for (int i = 0; i<length; i++) {
            
            for (int j = 0; j<length-1-i; j++) {
                
                //交换
                if (a[j] > a[j+1]) {
                    int temp = a[j];
                    a[j] = a[j+1];
                    a[j+1] = temp;
                }
                
                
            }
            
        }
        
        for (int i = 0; i<length; i++) {
            int temp = a[i];
            printf("temp = %d\n",temp);
        }
        
    }
    return 0;
}
